<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>项目名：</label>
                            <input type="text" name="projectName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:project:edit')}]];

    var addAccountFlag = [[${@permission.hasPermi('system:project:addAccount')}]];
    var queryAccountFlag = [[${@permission.hasPermi('system:project:queryAccount')}]];

    var removeFlag = [[${@permission.hasPermi('system:project:remove')}]];
    var prefix = ctx + "system/project";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "项目",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'projectName',
                    title: '项目名'
                },
                {
                    field: 'company',
                    title: '公司名'
                },
                {
                    field: 'deposit',
                    title: '押金'
                },
                {
                    field: 'cashoutMoney',
                    title: '可提现金额'
                },
                {
                    field: 'totalRevenue',
                    title: '总收益【正常分成收益】'
                },
                {
                    field: 'extractMoney',
                    title: '抽取收益金额'
                },
                {
                    field: 'notDeployedMoney',
                    title: '未部署设备收益'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // 编辑项目
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        // 添加账号
                        // actions.push('<a class="btn btn-primary btn-xs ' + addAccountFlag + '" href="javascript:void(0)" onclick="addAccount(\'' + row.id + '\')"><i class="fa fa-edit"></i>添加APP账号</a> ');

                        // 查看员工列表
                        // actions.push('<a class="btn btn-info btn-xs ' + queryAccountFlag + '" href="javascript:void(0)" onclick="queryAccount(\'' + row.id + '\')"><i class="fa fa-server"></i>查看账号列表</a> ');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function addAccount(projectId) {
        var url = prefix + "/addAccount/" + projectId;
        $.modal.open("添加APP登陆账号", url, 800, 300);
    }

    // 展示全部账号
    function queryAccount(projectId) {
        var url = prefix + "/queryAccount/" + projectId;
        var width = null;
        var height = null;
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
            width = 800;
        }
        if ($.common.isEmpty(height)) {
            height = 660;
        }
        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "查看APP账号",
            content: url,
            btn: ['关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            cancel: function (index) {
                return true;
            }
        });
    }
</script>
</body>
</html>